<%--
  Created by IntelliJ IDEA.
  User: dell
  Date: 2023/4/29
  Time: 20:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%--  前缀 c，核心包 --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--  为分页划分  --%>
<%@ page import="java.util.List" %>
<%@ page import="com.zyz.bookborrowing.bean.PageBean" %>
<%@ page import="com.zyz.bookborrowing.bean.Book" %>
<html>
<head>
    <title>Title</title>
</head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>

<script type="text/javascript">


    function deleteBook(bookId) {
        if (window.confirm("是否确定要删除编号为" + bookId + "的这本书呢？"))
            //页面控制台查看
            // console.log("确定要删除记录")
            location.href = "/bookServlet?type=delete&id=" + bookId;
    }
</script>


</head>


<body>

<div class="rightinfo">

    <div class="tools">

        <ul class="toolbar">
            <li>
                <a href="/book/bookUpdate.jsp">
                    <span><img src="images/t01.png" /></span>添加
                </a>
            </li>
        </ul>

    </div>

    <% PageBean<Book> list = (PageBean<Book>)request.getAttribute("list"); %>

    <table class="tablelist">
        <thead>
        <tr>
            <th>编号<i class="sort"><img src="images/px.gif" /></i></th>
            <th>书名</th>
            <th>作者</th>
            <th>出版社</th>
            <th>价格</th>
            <th>状态</th>
            <th>介绍</th>
            <th>出版日期</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
<%--        <c:forEach items="${requestScope.list}" var="book">--%>
        <c:forEach items="${list.pageData}" var="book">
            <tr>
                <td>${book.id}</td>
                <td>${book.bookName}</td>
                <td>${book.author}</td>
                <td>${book.publish}</td>
                <td>${book.price}</td>
                <td>
                    <c:if test="${book.state == 0}">
                        空闲
                    </c:if>
                    <c:if test="${book.state == 1}">
                        借阅
                    </c:if>
                    <c:if test="${book.state == 2}">
                        下架
                    </c:if>
                    <c:if test="${book.state == 3}">
                        其它
                    </c:if>
                </td>
                <td>${book.introduction}</td>
                <td>${book.pubdate}</td>
                <td>
                    <a href="/bookServlet?type=queryById&id=${book.id}" class="tablelink">修改</a>
                    <a href="JavaScript:deleteBook(${book.id})" class="tablelink">删除</a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>


    <div class="pagin">
        <div class="message">共<i class="blue">${list.totalPage}</i>条记录，当前显示第&nbsp;<i class="blue">${list.currentPage}&nbsp;</i>页</div>
        <ul class="paginList">
            <td class="paginItem"><a href="bookServlet?type=query&no=1">首页</a></td>
            <td class="paginItem"><a href="bookServlet?type=query&no=${list.currentPage-1}">上一页</a></td>
            <td class="paginItem"><a href="bookServlet?type=query&no=${list.currentPage+1}">下一页</a></td>
            <td class="paginItem"><a href="bookServlet?type=query&no=${list.totalPage}">尾页</a></td>
        </ul>
    </div>

</div>

</body>
</html>